home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / etc / trie-gen / test.cc < prev    next >
C/C++ Source or Header  |  1993-04-25  |  601b  |  29 lines

  1. /*
  2.    Tests the generated perfect has function.
  3.    The -v option prints diagnostics as to whether a word is in 
  4.    the set or not.  Without -v the program is useful for timing.
  5. */ 
  6.   
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. #define MAX_LEN 200
  11.  
  12. char *in_word_set (const char *, int);
  13.  
  14. int 
  15. main (int argc, char **argv)
  16. {
  17.   int   verbose = argc > 1 ? 1 : 0;
  18.   char  buf[MAX_LEN];
  19.   char *s;
  20.  
  21.   while (gets (buf)) 
  22.     if ((s = in_word_set (buf, strlen (buf))) && verbose)
  23.       printf ("%s is prefix for %s\n", buf, s);
  24.     else if (verbose) 
  25.       printf ("NOT in word set %s\n", buf);
  26.  
  27.   return 0;
  28. }
  29.